// index.js
// 获取应用实例
const app = getApp();
//引入封装好的request
const http = require("../../utils/http");


Page({
  data: {
    indicatorDots: true, //轮播是否有小圆点
    vertical: false, //false 横向   true 纵向
    autoplay: true, //自动播放
    interval: 2000, //动画时间
    duration: 500, //间隔时间
    circular: true, //衔接动画
    background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
    tuijianArr: [],
    swiperArr: [],
    guessListArr: [],
    activityData: [],
    activityDesc: ['不用懂外语', '不用懂攻略', '没有购物坑', '不用折腾自己'],
    activityCurrent: 0
  },
  // 跳转到搜索页
  goSearch() {
    wx.switchTab({
      url: '/pages/search/search',
    })
  },

  // 跳转内容页，传参
  goItem(ev) {
    console.log(ev);
    const id = ev.currentTarget.dataset.index;
    wx.navigateTo({
      url: '/pages/item/item?id=' + id,
    })
  },
  // 顶部轮播图
  onLoad: function () {
    http.request("product/banner/getBySeller/4bc4027c645343f09a964b5c2e9f875b", "", "get").then(res => {
      this.setData({
        swiperArr: res.data
      })
    });
    // 推荐列表
    http.request("product/product/getProductRecommendUser", {
      desc: false,
      orderBy: "top",
      pageNow: 1,
      pageSize: 20,
      seller_user_id: "4bc4027c645343f09a964b5c2e9f875b",
    }, "post").then(res => {
      this.setData({
        tuijianArr: res.data
      })
    })
    // 猜你喜欢
    http.request("product/product/guessYouLike", "", "get").then(res => {
      this.setData({
        guessListArr: res.data
      })
    })
    // 招募活动轮播图
    http.request("requirement/request/getMatchedProducts", {
      desc: false,
      orderBy: "outtime",
      pageSize: 100,
      product_type: 2,
    }, "post").then(res => {
      this.setData({
        activityData: res.data.matchedProducts
      })
    })
  },
})